package cn.com.bob.messageboard.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;

@Service
public class EmailServiceImpl {

    @Autowired
    private JavaMailSender mailSender;

    public void sendVerificationCode(String recipientEmail, String verificationCode) {
        String subject = "验证码";
        String content = "您的验证码是：" + verificationCode;

        SimpleMailMessage message = new SimpleMailMessage();
        message.setFrom("1294811773@qq.com");
        message.setTo(recipientEmail);
        message.setSubject(subject);
        message.setText(content);
        System.out.println(recipientEmail);
        System.out.println(message);

        mailSender.send(message);


        System.out.println("验证码已发送至邮箱：" + recipientEmail);
    }
}

